R=ZZ/149[a,b,c,e,f,m];

g0=-a^2*m^3+b*m^2-c*m+m^2; --these are the coefficients of y^3, z^3, y*z^2,y^2*z after linear term goes away
g1=2*a*m*b+c-a*c+m^2*e-m*f-3*a^3*m^2;
g2=(-m*b+a^2*b+2*a*m*e+e-a*f-3*a^4*m);
g3=(a*b+a^2*e+1-a^5);

f1=a^8*(3*g0*g2-9*g1^2); --f1,f2,f3 give equations which ensure that the cubic term is the cube of a linear form.
f2=a^4*(g0*g3-9*g1*g2);
f3=a^4*(3*g1*g3-9*g2^2);
f4=16*(-6*a^4*b+4*a^2*c+12*a^5*e-b^2+4*a*b*e-4*a^2*e^2-8*a*m-8*a^4*m-9*a^8); -- f4, f5, f6 come from CG
f5=16*a^4*(m*b+3*a^3*m*b-a*b*c+a^2*c*e-4*a^4*m*e-a^2*m^2+a^3*m^2-3*a^4*m+3*a^7*m);
f6=4*a^3*(-6*a^3*m*b+6*a^5*b+4*a*m*c+18*a^4*m*e-2*a*f+2*a^2*f-3*a^4*f+2*a*b^2+2*m*b*e-4*a^2*b*e-b*f+2*a*e*f-4*a*m*e^2+4*a-12*a^3*m^2-18*a^7*m-4*a^4-4*m^2);


R=ZZ/149[a,b,c,e,f,m];
f1=-a*b+a^2*e+1-a^5;
f2=a*(-m*b+a^2*b+2*a*m*e+e-a*f-3*a^4*m);
f3=64*a^4*(2*a*m*b+c-a*c+m^2*e-m*f-3*a^3*m^2);
f4=16*(-6*a^4*b+4*a^2*c+12*a^5*e-b^2+4*a*b*e-4*a^2*e^2-8*a*m-8*a^4*m-9*a^8);
f5=16*a^4*(m*b+3*a^3*m*b-a*b*c+a^2*c*e-4*a^4*m*e-a^2*m^2+a^3*m^2-3*a^4*m+3*a^7*m);
f6=4*a^3*(-6*a^3*m*b+6*a^5*b+4*a*m*c+18*a^4*m*e-2*a*f+2*a^2*f-3*a^4*f+2*a*b^2+2*m*b*e-4*a^2*b*e-b*f+2*a*e*f-4*a*m*e^2+4*a-12*a^3*m^2-18*a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